import 'package:flutter/material.dart';
import 'package:flutter_demo/pages/orderdiscount/common_head_widget.dart';
import 'package:flutter_demo/widgets/appbar.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class OrderDiscountPage extends StatelessWidget {
  OrderDiscountPage({Key? key}) : super(key: key);
  final OrderDiscountPageController vm = Get.put(OrderDiscountPageController());

  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Scaffold(
      appBar: MyAppBar(
        brightness: Brightness.dark,
        color: Colors.white,
        backgroundColor: Color.fromRGBO(70, 176, 254, 1),
        title: '订单优惠',
        hasback: true,
      ),
      body: Container(
        height: 1.sh,
        width: 1.sw,
        color: const Color.fromRGBO(247, 249, 252, 1),
        child: Stack(
          alignment: Alignment.topCenter,
          children: [
            ///第一层蓝色方块
            Image.asset(
              'assets/images/order/under.png',
              fit: BoxFit.cover,
            ),
            Column(
              mainAxisSize: MainAxisSize.min,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Stack(
                  alignment: Alignment.topCenter,
                  children: [
                    Padding(
                      padding: EdgeInsets.only(top: 22.w),
                      child: SizedBox(
                        width: 688.w,
                        child: Image.asset(
                          'assets/images/order/order_background.png',
                          fit: BoxFit.cover,
                        ),
                      ),
                    ),
                    Padding(
                      padding:
                          EdgeInsets.only(left: 60.w, right: 61.w, top: 84.w),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Column(
                                mainAxisAlignment: MainAxisAlignment.start,
                                mainAxisSize: MainAxisSize.min,
                                children: [
                                  Text(
                                    '订单号:',
                                    style: TextStyle(
                                        color:
                                            const Color.fromRGBO(57, 57, 57, 1),
                                        fontSize: 26.sp,
                                        height: 1,
                                        leadingDistribution:
                                            TextLeadingDistribution
                                                .proportional),
                                  ),
                                  Text('10325678',
                                      style: TextStyle(
                                          color: const Color.fromRGBO(
                                              57, 57, 57, 1),
                                          fontSize: 36.sp,
                                          height: 1,
                                          leadingDistribution:
                                              TextLeadingDistribution
                                                  .proportional))
                                ],
                              ),
                              Container(
                                alignment: Alignment.center,
                                width: 164.w,
                                height: 58.w,
                                decoration: BoxDecoration(
                                    color:
                                        const Color.fromRGBO(255, 255, 255, 1),
                                    borderRadius:
                                        BorderRadius.circular(19.5.w)),
                                child: const Text(
                                  '未优惠',
                                  style: TextStyle(
                                      color: Color.fromRGBO(244, 63, 58, 1)),
                                ),
                              ),
                            ],
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
                Container(
                  width: 688.w,
                  decoration: BoxDecoration(
                      color: const Color.fromRGBO(255, 255, 255, 1),
                      borderRadius: BorderRadius.only(
                          topLeft: Radius.zero,
                          topRight: Radius.zero,
                          bottomLeft: Radius.circular(15.w),
                          bottomRight: Radius.circular(15.w))),
                  child: Stack(
                    children: [
                      Column(
                        children: [
                          showRowInfo('车场信息：', '亲水体育馆', true, false),
                          splitLine(),
                          showRowInfo('绑定车牌：', '宁AX806Q', true, true),
                          splitLine(),
                          showRowInfo('停车优惠：', '3小时', false, false),
                          splitLine(),
                          Row(
                            children: [
                              SizedBox(
                                  width: 30.w,
                                  height: 30.w,
                                  child: Image.asset(
                                      'assets/images/order/warning.png')),
                              SizedBox(
                                width: 20.w,
                              ),
                              Text(
                                '当天消费，当天绑定，过期失效！',
                                style: normalTextStyle(),
                              )
                            ],
                          )
                        ],
                      ),
                      Positioned(
                          right: 13.w,
                          top: 50.w,
                          child: IconButton(
                            icon: SizedBox(
                                width: 21.w,
                                height: 12.w,
                                child: Image.asset(
                                    'assets/images/order/chose.png')),
                            onPressed: () {},
                          ))
                    ],
                  ),
                ),
              ],
            ),
            Positioned(
                width: 640.w,
                height: 100.w,
                bottom: 111.w,
                child: ElevatedButton(
                  onPressed: () {},
                  style: ButtonStyle(
                      shape: MaterialStateProperty.all(RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(10.w)))),
                  child: Text(
                    '订单优惠',
                    style: TextStyle(
                        color: const Color.fromRGBO(255, 255, 255, 1),
                        fontWeight: FontWeight.w800,
                        fontSize: 32.w),
                  ),
                ))
          ],
        ),
      ),
    ));
  }

  Divider splitLine() {
    return Divider(
      height: 50.w,
      thickness: 1.w,
      color: const Color.fromRGBO(229, 229, 229, 1),
    );
  }

  Row showRowInfo(String text, String getInfo, bool normalText, bool hasChose) {
    return Row(
      children: [
        Text(
          text,
          style: normalTextStyle(),
        ),
        Text(
          getInfo,
          style: normalText
              ? normalTextStyle()
              : TextStyle(
                  color: Color.fromRGBO(255, 169, 89, 1),
                  fontSize: 30.w,
                  fontWeight: FontWeight.normal,
                  height: 1,
                ),
        ),
        SizedBox(
          width: 280.w,
        ),
        // if (hasChose)
        //   SizedBox(
        //       width: 21.w,
        //       height: 12.w,
        //       child: Image.asset('assets/images/order/chose.png')),
      ],
    );
  }

  TextStyle normalTextStyle() {
    return TextStyle(
        color: Color.fromRGBO(57, 57, 57, 1),
        fontSize: 30.w,
        fontWeight: FontWeight.normal,
        height: 1,
        leadingDistribution: TextLeadingDistribution.even);
  }
}

class OrderDiscountPageController extends GetxController {}
